<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"/>
    <title>长乐美食城</title>
    <link rel="stylesheet" type="text/css" href="/Public/assets/home/images/favicon.ico">
    <link rel="stylesheet" type="text/css" href="/Public/vendor/slick/slick.css"/>
    <link rel="stylesheet" type="text/css" href="/Public/vendor/font-awesome/css/font-awesome.css"/>
    <link rel="stylesheet" type="text/css" href="/Public/assets/home/css/common.css"/>
    
</head>
<body>

<div class="logo">
    <h1><a href="index.html"><img class="img-responsive" src="/Public/assets/home/images/favicon.ico"
                                  alt="长乐美食城"/></a></h1>
    <h3>长乐美食城</h3>

    <div class="clears"></div>
</div>


    <div class="slick meun">
        <?php if(is_array($galleries)): $i = 0; $__LIST__ = $galleries;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$gallery): $mod = ($i % 2 );++$i;?><a href="javascript:void(0);">
                <img class="img-responsive" src="<?php echo ($gallery["img"]); ?>" alt="图片一" style="width: 354px;height: 222px;"/>
            </a><?php endforeach; endif; else: echo "" ;endif; ?>
    </div>

    <section class="detail">
        <hgroup class="product">
            <h1><?php echo ($product["name"]); ?></h1>
            <h2>¥ <?php echo ($product["price"]); ?>元</h2>
        </hgroup>
        <p><?php echo (htmlspecialchars_decode($product["description"])); ?></p>
    </section>

    <section class="operate">
        <a id="btn-buy" href="javascript:void(0);" data-id="<?php echo ($product["id"]); ?>">立即购买</a>
        <span id="btn-cart-plus" href="javascript:void(0);" data-id="<?php echo ($product["id"]); ?>">加入购物车</span>
    </section>


<?php if(($product_num) > "0"): ?><a href="<?php echo U('Cart/index');?>" id="btn-cart"><i class="fa fa-shopping-cart"></i><span><?php echo ($product_num); ?></span></a><?php endif; ?>
<a href="javascript:;" id="to_top" onclick="goTop();return false;">返回</a>

<div class="footer">
    <p>
        <a href="<?php echo U('Index/index');?>">商城首页</a>
        <a href="<?php echo U('Cart/index');?>">购物车</a>
        <a href="<?php echo U('Customer/index');?>">会员中心</a>
    </p>

    <dl>
        <dt><a href="javascript:void(0);">
            <img class="img-responsive" src="/Public/assets/home/images/favicon.ico"
                                               alt="长乐美食城"/></a></dt>
        <dd><a href="javascript:void(0);">武汉长乐未央网络科技有限公司提供技术支持</a></dd>
    </dl>
</div>

<script type="text/javascript" src="/Public/assets/home/js/jquery.min.js"></script>
<script type="text/javascript" src="/Public/vendor/slick/slick.js"></script>
<script type="text/javascript" src="/Public/assets/home/js/index.js"></script>

    <script>
        $(function () {
            //加入购物车:只是把商品添加到了购物车，不跳转到购物车
            $("#btn-cart-plus").click(function () {
                var id = $(this).data('id');
                $.post("<?php echo U('Cart/add_cart');?>", {id: id}, function (data) {
                    if (data.status != 1) {
                        alert(data.info);
                        location.href = "<?php echo U('Customer/login');?>";
                    } else {
                        alert(data.msg);
                        window.location.reload();
                        return false;
                    }
                });
                return false;
            })

            //立即购买,添加商品到购物车并跳转
            $("#btn-buy").click(function () {
                var id = $(this).data('id');
                $.post("<?php echo U('Cart/add_cart');?>", {id: id}, function (data) {
                    if (data.status != 1) {
                        alert(data.info);
                        location.href = "<?php echo U('Customer/login');?>";
                    } else {
                        location.href = "<?php echo U('Cart/index');?>";
                    }
                });
                return false;
            })
        })
    </script>

</body>
</html>